package service;

import mapper.BusinessMapper;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import pojo.Business;
import util.SqlSessionFactoryUtil;

public class BusinessService {
    private final SqlSessionFactory sqlSessionFactory = SqlSessionFactoryUtil.getSqlSessionFactory();

    /**
     * 插入一条售票业务记录
     * @param business售票业务对象
     */
    public void addBusiness(Business business) {
        SqlSession sqlSession = sqlSessionFactory.openSession();
        BusinessMapper mapper = sqlSession.getMapper(BusinessMapper.class);

        mapper.addOne(business);

        sqlSession.commit();
        sqlSession.close();
    }
}